<?php TPL::output('m/header.tpl.htm'); ?>

<?php if ($this->redirect_message) { ?>
<?php foreach ($this->redirect_message AS $key => $message) { ?>
	<div class="alert alert-warning"><?php echo $message; ?></div>
<?php } ?>
<?php } ?>

<!-- 内容 -->
<div class="container padding-0">
	<!-- 话题信息 -->
	<div class="aw-topic-detail">
		<div class="mod-head clearfix">
			<a class="img"><img width="50" src="<?php echo get_topic_pic_url('max', $this->topic_info['topic_pic']); ?>" alt="" /></a>
			<div class="title clearfix">
				<h1 class="pull-left"><?php echo $this->topic_info['topic_title']; ?></h1>
				<?php if ($this->user_id) { ?>
				<span class="pull-right">
					<a class="btn btn-success btn-mini <?php if ($this->topic_info['has_focus']) { ?> active<?php } ?>" onclick="AWS.User.follow($(this), 'topic', <?php echo $this->topic_info['topic_id']; ?>);"><?php if ($this->topic_info['has_focus']) { ?><?php _e('取消关注'); ?><?php } else { ?><?php _e('关注'); ?><?php } ?></a>
				</span>
				<?php } ?>
			</div>
			<p class="color-999"><?php _e('%s 个讨论', $this->topic_info['discuss_count']); ?>  •  <?php echo $this->topic_info['focus_count']; ?> <?php _e('个关注'); ?></p>
		</div>
		<div class="mod-footer clearfix">
			<ul>
				<li class="active">
					<a href="#new" role="tab" data-toggle="tab"><?php _e('全部'); ?></a>
				</li>
				<li>
					<a href="#best" role="tab" data-toggle="tab"><?php _e('精华'); ?></a>
				</li>
				<li>
					<a href="#recommend" role="tab" data-toggle="tab"><?php _e('推荐'); ?></a>
				</li>
				<li>
					<a href="#description" role="tab" data-toggle="tab"><?php _e('话题详述'); ?></a>
				</li>
			</ul>
		</div>
	</div>
	<!-- end 话题信息 -->

	<div class="aw-box">
		<div class="tab-content">
			<!-- 最新 -->
			<div class="tab-pane active" id="new">
				<div class="aw-question-list active">
					<div class="mod-body">
						<ul id="all_posts_listview"></ul>
					</div>
					<div class="mod-footer">
						<a class="aw-load-more" id="load_all_posts"><i class="icon icon-loading icon-spin"></i> <span><?php _e('更多'); ?></span></a>
					</div>
				</div>
			</div>
			<!-- end 最新 -->
			<!-- 精华 -->
			<div class="tab-pane" id="best">
				<div class="aw-feed-list active">
					<div class="mod-body">
						<ul id="best_answers_listview"></ul>
					</div>
					<div class="mod-footer">
						<a class="aw-load-more" id="load_best_answers"><i class="icon icon-loading icon-spin"></i> <span><?php _e('更多'); ?></span></a>
					</div>
				</div>
			</div>
			<!-- end 精华 -->
			<!-- 推荐 -->
			<div class="tab-pane" id="recommend">
				<div class="aw-question-list active">
					<div class="mod-body">
						<ul id="recommend_answers_listview"></ul>
					</div>
					<div class="mod-footer">
						<a class="aw-load-more" id="load_recommend_answers"><i class="icon icon-loading icon-spin"></i> <span><?php _e('更多'); ?></span></a>
					</div>
				</div>
			</div>
			<!-- end 推荐 -->
			<!-- 描述 -->
			<div class="tab-pane" id="description">
				<div class="mod card-mod">
					<div class="mod-head">
						<?php echo $this->topic_info['topic_description']; ?>
					</div>
				</div>
			</div>
			<!-- end 描述 -->
		</div>

		<!-- 最佳回答者 -->
		<?php if (is_array($this->best_answer_users)) { ?>
		<div class="aw-explore-hot-topic">
			<div class="mod-head">
				<h3><?php _e('最佳回复者'); ?></h3>
			</div>
			<div class="mod-body">
				<ul>
					<?php foreach ($this->best_answer_users AS $key => $val) { ?>
					<li>
						<a class="pull-left" href="m/people/<?php echo $val['user_info']['url_token']; ?>"><img src="<?php echo get_avatar_url($val['user_info']['uid'], 'mid'); ?>" alt="" width="50" /></a>
						<div class="content pull-left">
							<a href="m/people/<?php echo $val['user_info']['url_token']; ?>"><?php echo $val['user_info']['user_name']; ?></a>
							<p class="color-999">
								<?php _e('获得'); ?> <?php _e('%s 次赞同', '<b>' . $val['agree_count'] . '</b>'); ?>, <?php _e('%s 次感谢', '<b>' . $val['thanks_count'] . '</b>'); ?>
							</p>
						</div>
					</li>
					<?php } ?>
				</ul>
			</div>
		</div>
		<?php } ?>
		<!-- end 最佳回答者 -->
	</div>
</div>

<script type="text/javascript">
	var TOPIC_ID = '<?php echo $this->topic_info['topic_id']; ?>';
	
	var CONTENTS_TOPIC_ID = '<?php echo $this->contents_topic_id; ?>';
	var CONTENTS_TOPIC_TITLE = '<?php echo $this->contents_topic_title; ?>';
	
	$(document).ready(function () {
		if ($('#all_posts_listview').length)
		{
			AWS.load_list_view(G_BASE_URL + '/explore/ajax/list/sort_type-new__topic_id' + '-' + CONTENTS_TOPIC_ID, $('#load_all_posts'), $('#all_posts_listview'), 1);
		}

		if ($('#recommend_answers_listview').length)
		{
			AWS.load_list_view(G_BASE_URL + '/explore/ajax/list/sort_type-new__is_recommend-1__topic_id' + '-' + CONTENTS_TOPIC_ID, $('#load_recommend_answers'), $('#recommend_answers_listview'), 0);
		}
		
		if ($('#best_answers_listview').length)
		{
			AWS.load_list_view(G_BASE_URL + '/topic/ajax/question_list/type-best__topic_id' + '-' + CONTENTS_TOPIC_ID, $('#load_best_answers'), $('#best_answers_listview'), 0);

		}
	});
</script>

<?php TPL::output('m/footer.tpl.htm'); ?>